package simulation;

/**
 * 替换所有的问号
 */
public class Demo20250517 {
    public String modifyString(String s) {
        int n = s.length();
        char[] array = s.toCharArray();
        for (int i = 0; i < array.length; i++) {
            if (array[i] == '?') {
                for (char ch = 'a'; ch <= 'z'; ch++) {
                    if ((i == 0 || ch != array[i - 1])
                            && (i == n - 1 || ch != array[i + 1])) {
                        array[i] = ch;
                        break;
                    }
                }
            }
        }
        return String.valueOf(array);
    }
}
